package com.share.thread;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @desc:
 * @author:caifan
 * @date:2022/4/2
 */
public class CountDownLatchDemo01 {

    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch  = new CountDownLatch(5);
        ExecutorService pool = Executors.newFixedThreadPool(5);
        for (int i = 1; i <= 5; i++) {
            int finalI = i;
            pool.submit(() -> {
                System.out.println(finalI + "号运动员准备好了");
                countDownLatch.countDown();
            });
        }
        countDownLatch.await();
        System.out.println("开始跑步");
        pool.shutdown();
    }

}
